import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, __dirname);
  return {
    base: '/h5',
    plugins: [
      vue()
    ],
    server: {
      port: 5000,
      host: '0.0.0.0',
      cors: true,
      proxy: { // 配置跨域
        "/api": {
          target: env.VITE_BASE_URL,
          changeOrigin: true,
          // 前端加api，拦截接口到后端服务器
          rewrite: (path) => path.replace(/^\/api/, "/api"),
        },
      }
    }
  }
})
